﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="LogHandle_List.aspx.cs" Inherits="ncp.Web.cms.LogHandle_List" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="../../themes/icon.css" />
	<script type="text/javascript" src="../../js/jquery-1.7.1.min.js"></script>
	<script type="text/javascript" src="../../js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../js/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../../../js/common.js"></script>
</head>
<body style="margin:0; padding:0px;">
    <form id="form1" runat="server">
        <div class="toolbar" style="background-color:#efefef; font-size:12px;">
            <input id="Radio1" name="rdoHandle" type="radio" checked="checked" />查看用户操作日志
            <input id="Radio2" name="rdoHandle" type="radio" />查看客户操作日志
            <a href="#" class="easyui-linkbutton" plain="true" iconCls="icon-search" onclick="onSearch();">查询</a>
        </div>
        <div id="divright">    
        </div>
	</form>
</body>
</html>
<script type="text/javascript">
    var pageobj = new Object();
    $(function() {
        initPageObj();
        initDatagrid();
        LoadHandleInfo();
        initPager();
    });
    
    //初始化页码对象
    function initPageObj() {
        pageobj.currentpageindex = 1;
        pageobj.pagesize = 10;
        pageobj.sorting = "Log_Id";
        pageobj.sortdir = "desc";
        pageobj.currentwhere = GetstrWhere();
        pageobj.recordcount = GetRecordCount();
    }

    //初始化表格
    function initDatagrid() {
        var myField1 = "";
        var myField2 = "";
        if ($("#Radio1").attr("checked")) {
            myField1 = "User_Account";
            myField2 = "User_Name";
        }
        else {
            myField1 = "Client_Account";
            myField2 = "Client_Name";
        }
        $('#divright').datagrid({
            width: 'auto',
            height: 350,
            nowrap: true,
            striped: true,
            singleSelect: true,
            sortName: 'Log_Id',
            sortOrder: 'desc',
            remoteSort: false,
            idField: 'Log_Id',
            pagination: true,
            rownumbers: true,
            columns: [[
					{ field: 'Log_Id', title: 'ID', sortable: 'true', width: 80 },
					{ field:  myField1, title: '用户帐号', sortable: 'true', width: 120 },
					{ field: myField2, title: '用户名称', sortable: 'true', width: 120 },
					{ field: 'Handle_Note', title: '操作内容', sortable: 'true', width: 120, align: 'center' },
					{ field: 'Handle_Time', title: '操作时间', sortable: 'true', width: 120, align: 'center',
					    formatter: function(value, rec) {
					        return value.replace(" 00:00:00", "");
					    }
					},
					{ field: 'ComputerName', title: '客户端环境', sortable: 'true', width: 120, align: 'center' },
					{ field: 'ComputerIP', title: '客户端IP', sortable: 'true', width: 120, align: 'center' }
				]]
        });
    }

    function initPager() {
        var p = $('#divright').datagrid('getPager');
        $(p).pagination({
            total: pageobj.recordcount,
            pageSize: pageobj.pagesize,
            pageList: [10, 15, 20, 25, 30],
            showRefresh: true,
            showPageList:true,
            beforePageText: '第',
            afterPageText: '页 共 {pages} 页',
            displayMsg: '当前显示 {from} - {to} 条记录 共 {total} 条记录',
            onSelectPage: function(pageNumber, pageSize) {
                $(this).pagination('loading');
                onShowPageNo(pageNumber, pageSize);
                $(this).pagination('loaded');
            },
            onBeforeRefresh: function(pageNumber, pageSize) {
                $(this).pagination('loading');
                onRefreshPageNo(pageNumber, pageSize);
                $(this).pagination('loaded');
            }
        });
    }
    
    //翻页
    function onShowPageNo(pageNumber, pageSize) {
        pageobj.pagesize = pageSize;
        pageobj.currentpageindex = pageNumber;
        LoadHandleInfo();
        initPager();
        return false;
    }
    
    //刷新
    function onRefreshPageNo(pageNumber, pageSize) {
        initPageObj();
        return false;
    }
    
    //得到条件
    function GetstrWhere() {
        var myWhere = "";
        if ($("#Radio1").attr("checked")) myWhere = "User_Id<1000";
        else myWhere = "User_Id>=1000";
        return myWhere;
    }

    //得到总记录数
    function GetRecordCount() {
        var response = ncp.Web.cms.LogHandle_List.GetRecordCount(pageobj.currentwhere);
        if (response.value != null) {
            return response.value;
        }
        else
            return 0;
    }

    //查询
    function onSearch() {
        pageobj.currentpageindex = 1;
        pageobj.currentwhere = GetstrWhere();
        pageobj.recordcount = GetRecordCount();
        initDatagrid();
        LoadHandleInfo();
        initPager();
        return false;
    }

    //装载客户信息视图
    function LoadHandleInfo() {
        var jsonStr = $.objectToJson(pageobj);
        var data = eval(ncp.Web.cms.LogHandle_List.BindTable(jsonStr).value);
        $('#divright').datagrid('loadData', data);
    }
</script>
